package com.healer.springcloud.service;

import com.healer.springcloud.pojo.Department;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;
//降级~
@Component
public class DepartmentClientServiceFallBackFactory implements FallbackFactory {
    @Override
    public DepartmentClientService create(Throwable throwable) {
        return new DepartmentClientService() {
            @Override
            public boolean addDepartment(String name) {
                return false;
            }

            @Override
            public Department queryDepartmentById(Map<String, Object> map) {
                return new Department(Long.parseLong(map.get("id").toString()),
                        "没有和这个id对应的部门",
                        "no database in mysql");
            }

            @Override
            public List<Department> queryDepartment() {
                return null;
            }
        };
    }
}
